<!--单项目首页 -->
<template>
  <div class="singlePage">
    <div v-if="$route.name === '工作空间'">
      <div class="singleMain">
        <div class="leftSingle">
          <div class="myApply">
            <div class="title">
              {{$t('projectMain.title.myApp')}}
              <a-tooltip>
                <template slot="title">
                编辑应用
                </template>
                <span class="editApply" @click="editApply"
                ><a-icon type="form" class="iconfont" /></span
              >
              </a-tooltip>
            </div>
            <iconText
              v-if="newIconList.length !== 0"
              :iconTextList="newIconList"
              @showModal="showModal"
            ></iconText>
            <a-empty v-else description="暂无数据" class="nodata" />
          </div>
          <div class="projectNav">
            <div class="title">
              {{$t('projectMain.title.projectNavigation')}}
            </div>
            <div class="stepProgress" v-if="stepList.length !== 0">
              <stepBar :stepList="stepList"></stepBar>
            </div>
            <a-empty v-else description="暂无数据" class="nodata" />
          </div>
          <div class="detailMes">
            <div class="title">
               {{$t('projectMain.title.detailInfo')}}
            </div>
            <div v-if="messList.length > 0 ">
              <div
                class="messageContent"
                v-for="(item, index) in messList"
                :key="index"
              >
                <div
                  v-for="(item1, index1) in item.rows"
                  class="message"
                  :key="index1"
                >
                  <div
                    v-for="(item2, index2) in item1.items"
                    class="messageList"
                    :key="index2"
                  >
                    <detailMessage :attrList="item2"></detailMessage>
                  </div>
                </div>
              </div>
            </div>
            <a-empty v-else description="暂无数据" class="nodata" />
          </div>
          <!-- <div class=" relationProduct" v-if="projectType ==='产品开发项目' || projectType ==='关键零部件开发项目'">
            <div class="container">
              <div class="title">
              {{$t('projectMain.title.relatedProducts')}} 
              </div>
              <div class="inputSearch" v-if="hasPermission">
                <a-select
                  show-search
                  :value="selectedItems"
                  placeholder="请输入"
                  :default-active-first-option="false"
                  :show-arrow="false"
                  :filter-option="false"
                  style="min-width: 200px;max-width: 880px;"
                  @change="findProduct"
                  @search="fetchProduct"
                >
                  <a-spin v-if="fetching" slot="notFoundContent" size="small" />
                  <a-select-option
                    v-for="(item) in filteredOptions"
                    :key="item.oid"
                  >
                    {{ item.partMsg }}
                  </a-select-option>
                </a-select>
                <span @click="addProduct" class="add">
                  {{$t('projectMain.title.add')}}
                </span>
              </div>
            </div>
            <div class="product">
              <div class="title">产品编码:</div>
              <div class="codeContainer">
                  <div
                    v-for="(item, index) in productList"
                    :key="index"
                    class="productName"
                  >
                    <span @click="goProduct(item)">{{ item.partMsg
                    }}</span><a-icon
                      v-if="hasPermission"
                      type="close"
                      class="deleteProduct"
                      @click="deleteProduct(item)"
                    />
                  </div>
              </div>
            </div>
          </div> -->
      </div>
      <div class="rightSingle">
        <div class="topRightSingle">
          <div class="title">
           {{$t('projectMain.title.quickFunctionEntrace')}}
          </div>
          <a-carousel>
            <div class="content">
              <div class="gspTop">
                <div class="GSPName">
                  <span class="name">GSP</span>
                </div>
                <div>
                  <a-anchor :affix="false" @click="handleCilck"  :showInkInFixed="true">
                    <a-anchor-link :title="item.name" :href="item.url" v-for="(item,index) in gspList" :key="index">
                    </a-anchor-link>
                  </a-anchor>
                </div>     
              </div>
              <div class="gspBottom">
                <div class="GSPName">
                  <span class="name">MDM</span>
                </div>
                <div>
                  <a-anchor :affix="false" @click="handleCilck" :showInkInFixed="true">
                    <a-anchor-link :title="item.name" :href="item.url" v-for="(item,index) in mdmList" :key="index" :class="isMdm ? '' : 'default'" :target="isMdm ? '_blank' : null">
                    </a-anchor-link>
                    <!-- <a-anchor-link :title="'产成品编码申请'" :href="productUrl" key="999">
                    </a-anchor-link> -->
                  </a-anchor>
                </div>     
              </div>
            </div>
          </a-carousel>
        </div>
        <div class="bottomRightSingle">
          <div class="projectBoard">
          <div class="title">
            {{$t('projectMain.title.projectBoard')}}
          </div>
          <div class="boardContainer">
            <div class="chart">
              <a-progress @click="routerPage('计划')" type="circle" :percent="projectAchieve" strokeColor="#75d06c" :strokeWidth="7" :width="150">
              </a-progress>
              <div class="complete">项目完成率</div>
            </div>
            <div class="divider"></div>
            <div class="boardContent">
              <div @click="routerPage('问题')">
                <projectBoard
                  :board="solutionQuestion"
                  v-if="Object.keys(solutionQuestion).length !== 0"
                ></projectBoard>
              </div>
              <div class="dividerLeft"></div>
              <div @click="routerPage('风险')">
                <projectBoard
                  :board="solutionRisk"
                  v-if="Object.keys(solutionRisk).length !== 0"
                ></projectBoard>
              </div>
            </div>
            </div>
          </div>
        </div> 
      </div>
    </div>
      <commonModal
        class="modalEditApply"
        :titleModal="EditApply"
        :key="state"
        :visibleModal="visibleModalEditApply"
        :widthModal="widthModalEditApply"
        @handleOk="handleOKEditApply"
        @handleCancel="handleCancelEditApply"
      >
        <drag-sort :applyList="applyList" :moreList="moreList" @dragged="dragged"
          @deleteApply="dragged" @addApply="dragged"
        ></drag-sort>
      </commonModal>
      <commonModal
        class="modalStatus"
        :titleModal="setStatus"
        :visibleModal="visibleModalStatus"
        :widthModal="widthModalStatus"
        @handleOk="handleOKStatus"
        @handleCancel="visibleModalStatus = false"
      >
        <div class="selectStatus">
          <div class="targetStatus">目标状态 :</div>
          <a-select style="width: 100%" v-model="statusNow">
            <a-select-option
              :key="index"
              :value="item.value"
              v-for="(item, index) in targetStatusList"
            >
              {{ item.lable }}
            </a-select-option>
          </a-select>
        </div>
      </commonModal>
      <uploadDeliver :uploadModalVisible="visibleDeliver" @closeUploadModal="closeUploadModal" @submitDeliver="closeUploadModal" ref="deliver"></uploadDeliver>
    </div>
    <!--<router-view v-else></router-view>-->
    <router-view  v-if="$route.name !== '工作空间' && !$route.meta.keepAlive"></router-view>
    <keep-alive>
    <router-view  v-if="$route.name !== '工作空间' && $route.meta.keepAlive"></router-view>
    </keep-alive>
    
  </div>
</template>
<script>
import iconText from "./comp/icontext";
import detailMessage from "@/components/singlePage/detailMessage";
import projectBoard from "@/components/singlePage/projectBoard";
import stepBar from "./comp/stepBar";
import commonModal from "@/components/singlePage/commonModal";
import DragSort from "./comp/dragSort";
import uploadDeliver from "./comp/upload-deliver"
import { myApplyList, judgeApply, projectNav, improveNav, techStudyNav, compSoftNav, embSoftNav, GSPList, MDMList } from "@utils/constant/constant";
import { getTaskBookByProject, hasCreatePermission } from '@/api/taskBook';
import { Message } from "ant-design-vue";
import {
  postHomePageApply,
  getProjectNodeList,
  getDetailMessage,
  getSummaryData,
  getConclusion,
  getRelationProduct,
  getProjectAchieve,
  getQuestion,
  getRisk,
  findRelationProject,
  addRelationProject,
  removeRelationProject,
  updateProgress,
  getTemplateStatus,
  setTemplateStatus,
  getMyApply,
  setMyApply,
  getProjectAuthority,
  sendThingworxData,
} from "@api/singleProject";
  import { getCheckList, checkCreateKnotItemBook } from "@/api/projectAccepApi.js"
let timeout;
let currentValue;
let userinfo = JSON.parse(sessionStorage.getItem('userInfo'))
import {iconList} from './dataBase.js'
export default {
  name: "singlePage",
  components: {
    iconText,
    detailMessage,
    projectBoard,
    stepBar,
    commonModal,
    DragSort,
    uploadDeliver
  },
  data() {
    return {
      isMdm: false,
      gspList: GSPList,
      mdmList: MDMList,
      productUrl: "http://dm.sany.com.cn/mdm/",
      state: 0, //应用model框的key值
      EditApply: "我的应用编辑",
      visibleModalEditApply: false, 
      widthModalEditApply: 1130,
      setStatus: "设置状态",
      statusNow: '', // 当前状态
      visibleModalStatus: false,
      targetStatusList: [], // 目标状态
      widthModalStatus: 500,
      iconTextList: [], // 应用编辑
      productList: [], // 关联产品编码展示
      messList: [], // 详细信息
      projectAchieve: 0, // 项目进度完成
      solutionQuestion: {}, // 问题数
      solutionRisk: {}, // 风险数
      selectedItems: undefined,
      filteredOptions: [], // 关联产品
      stepList: [], // 项目导航
      commonParams: {
        oid: this.$route.query.oid ? `OR:com.pisx.pmgt.project.PIProject:${this.$route.query.oid}` : `OR:com.pisx.pmgt.project.PIProject:${sessionStorage.getItem("oid")}` ,
        userId: userinfo.loginName
      },
      visibleDeliver: false,//上传交付物弹框
      moreList: [], // 更多应用
      applyList:[], // 应用入口
      fetching: false,
      draggedList: "", // 排序后的应用
      noDragList: "", // 未排序的应用
      newIconListArr: [],// 交集的应用
      hasPermission: false, // 添加关联产品的权限
      projectType: JSON.parse(sessionStorage.getItem('ProjectObj')).projectType, //项目类型
      projectSmallType: sessionStorage.getItem("projectSmallType"), // 项目小类
      projectId: "",
      /**验收表内容 */
      acceptList: [],
      projectOid: sessionStorage.getItem('oid'),
      hasTaskBook: false
    };
  },
  computed: {
    newIconList: function (){
      // let newMixData = []
      // if(this.noDragList !=="" && this.noDragList.length !== 0){
      //   this.noDragList.forEach(item=>{
      //     this.iconTextList.forEach(i=>{
      //       if(i.id === item){
      //         newMixData.push({
      //           name: i.name,
      //           id: i.id,
      //           show: true,
      //           icon: i.icon,
      //           number: i.number,
      //           url: i.url
      //         })
      //       }
      //     })
      //   })
      // }else{
      //   newMixData = this.iconTextList
      // }
      let newMixData = iconList
      return newMixData
    },
  },
  mounted() {
    this.init()
  },
  watch:{
    $route(to, from){
      this.projectId = this.$route.query.oid
      if(from.path === "/projectManage" && to.path ==="/single/projectMain" && this.$route.query.oid !== undefined){
        console.log('344');
        // this.commonParams.oid = `OR:com.pisx.pmgt.project.PIProject:${this.$route.query.oid}`
        this.init()
      }
      if(from.path === "/single/projectMain/editProject" && to.path ==="/single/projectMain"){
        this.init()
      }
    },
    projectId(n) {
      this.projectOid = n || sessionStorage.getItem('oid')
      this.commonParams.oid = `OR:com.pisx.pmgt.project.PIProject:${n}`
      this.init()
    }
  },
  methods: {
    routerPage(val) {
      if (val === '问题') {
        this.$router.push({
          path: '/single/questionSingle'
        });
      } else if (val === '风险') {
        this.$router.push({
          path: '/single/riskSingle'
        });
      } else if (val === '计划') {
        this.$router.push({
          path: '/single/projectPlan'
        });
      }
    },
    // 初始化
    init() {
      console.log('344');
      this.commonParams.oid = `OR:com.pisx.pmgt.project.PIProject:${this.projectOid}`
      this.judgeApplyAuth();
      this.getProjectNode();
      this.getDetailMessage();
      this.getRelationProduct();
      this.projectBoard();
      this.getMyApply();
      this.getProjectAuthority()
      this._getTaskBookByProject()
    },
    // 判断项目首页应用权限
    judgeApplyAuth() {
      let _ = this
      const params = judgeApply;
      params.userId = _.commonParams.userId;
      params.oid = _.commonParams.oid;
      postHomePageApply(params).then(res => {
        if (res && res.status === 200) {
          if(res.data.success){
            if(res.data.data.length > 0) {
              myApplyList.forEach((n,x) => {
                res.data.data.forEach((m,y) => {
                  if(n.id.indexOf(m.id) !== -1){
                  Object.assign(n,m)
                }
                })
              })
            } 
          const authorityList = myApplyList.filter(item=>{
            return item.show === true
          })
          _.iconTextList = authorityList;
          this._hasCreatePermission()
          }else {
          // Message.error(res.data.detailMessage);
          } 
        }else{
          Message.error("查询失败");
        }
      });
    },
    // 表格数据
    _getTaskBookByProject() {
      getTaskBookByProject({ oid: this.commonParams.oid, userId: userinfo.loginName }).then(({data}) => {
        if (data.success && data.data && data.data.length) {
          this.hasTaskBook = true
        }
      })
    },
    // 根据产品编码跳转
    goProduct(item) {
      if(item.partUrl){
        window.open(item.partUrl,"_blank")
      }
    },
    // 获取项目权限
    getProjectAuthority() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
        number: "83"
      }
      getProjectAuthority(params).then(res=>{
        if(res && res.status === 200){
          if(res.data &&  res.data.data !== "" && res.data.success){
            this.hasPermission = res.data.data[0].hasPermission
          } 
        }else{
            Message.error("查询失败")
          } 
      })
    },
    // 获取我的应用
    getMyApply() {
      getMyApply().then(res=>{
        if(res.data.myAppList){
          const newArr = res.data.myAppList.split(",")
          this.noDragList = newArr
        }else{
          this.noDragList =[]
        }
      })
    },
    // gsp跳转
    handleCilck(e,link) {
      // if(this.isMdm) {
      //   e.preventDefault()
      //   window.open(link.href,"_blank")
      // }
    },
    // 获取项目关键节点清单
    getProjectNode() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getProjectNodeList(params).then(res => {
        if (res && res.status === 200) {
          if(res.data && res.data.data !== "" && res.data.success){
            if(this.projectType === "产品开发项目" ||  this.projectType === "关键零部件开发项目"){
              res.data.data.forEach((n,x) => {
                let children = [];
                projectNav.forEach((m,y) => {
                  if(n.name.indexOf(m.name) !== -1){
                    n.children = Object.assign(children, m.children)
                  }
                })
              })
              this.stepList = res.data.data;
            }
            if(this.projectType === "研发能力提升项目"){
              res.data.data.forEach((n,x) => {
                let children = [];
                improveNav.forEach((m,y) => {
                  if(n.name.indexOf(m.name) !== -1){
                    n.children = Object.assign(children, m.children)
                  }
                })
              })
              this.stepList = res.data.data;
            }
            if(this.projectType === "技术研究与开发项目"){
              res.data.data.forEach((n,x) => {
                let children = [];
                techStudyNav.forEach((m,y) => {
                  if(n.name.indexOf(m.name) !== -1){
                    n.children = Object.assign(children, m.children)
                  }
                })
              })
              this.stepList = res.data.data;
            }
            if(this.projectType === "软件开发项目" &&  this.projectSmallType === "计算机软件"){
              res.data.data.forEach((n,x) => {
                let children = [];
                compSoftNav.forEach((m,y) => {
                  if(n.name.indexOf(m.name) !== -1){
                    n.children = Object.assign(children, m.children)
                  }
                })
              })
              this.stepList = res.data.data;
            }
            if(this.projectType === "软件开发项目" &&  this.projectSmallType === "嵌入式软件"){
              res.data.data.forEach((n,x) => {
                let children = [];
                embSoftNav.forEach((m,y) => {
                  if(n.name.indexOf(m.name) !== -1){
                    n.children = Object.assign(children, m.children)
                  }
                })
              })
              this.stepList = res.data.data;
            }
          }
        } else {
          Message.error("查询失败");
        }
      });
    },
    // 获取详细信息
    getDetailMessage() {
      this.messList = []
      var numbers = null;
      let arr = [{"label":"","sort":"","rows":[{"sort":"0","items":[{"label":"编码","id":"projectShortName","valueType":"String","value":"09003094","valueInner":"09003094","valueLink":null,"required":true,"formType":null,"singleLine":true,"row":0,"col":0,"selects":null},{"label":"项目小类","id":"ProjectSmallType","valueType":"String","value":"嵌入式底层软件","valueInner":"嵌入式底层软件","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":0,"col":1,"selects":null},{"label":"开展方式","id":"modeofdevelopment","valueType":"String","value":"对外合作（对供应商合作）","valueInner":"对外合作（对供应商合作）","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":0,"col":2,"selects":null},{"label":"创建者","id":"creator","valueType":"TypeInstanceIdentifier","value":"王志伟","valueInner":"wangzw14","valueLink":"http://pdmlink.sany.com.cn/Windchill/app/#ptc1/tcomp/infoPage?oid\u003dOR%3Awt.org.WTUser%3A18411389593\u0026u8\u003d1","required":false,"formType":null,"singleLine":null,"row":0,"col":3,"selects":null}]},{"sort":"1","items":[{"label":"名称","id":"projectName","valueType":"String","value":"测试0314-02","valueInner":"测试0314-02","valueLink":null,"required":true,"formType":null,"singleLine":true,"row":1,"col":0,"selects":null},{"label":"重要等级","id":"ImportantGrade","valueType":"String","value":"A","valueInner":"A","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":1,"col":1,"selects":null},{"label":"内部订单号","id":"InternalOrderNumber","valueType":"String","value":null,"valueInner":null,"valueLink":null,"required":false,"formType":null,"singleLine":null,"row":1,"col":2,"selects":null},{"label":"创建时间","id":"thePersistInfo.createStamp","valueType":"Timestamp","value":"2022/03/14","valueInner":"2022/03/14","valueLink":null,"required":false,"formType":null,"singleLine":null,"row":1,"col":3,"selects":null}]},{"sort":"2","items":[{"label":"简称","id":"projectAbbreviation","valueType":"String","value":"测02","valueInner":"测02","valueLink":null,"required":true,"formType":null,"singleLine":true,"row":2,"col":0,"selects":null},{"label":"所属组织","id":"projectGroupReference","valueType":"TypeInstanceIdentifier","value":"重机事业部-大挖研究院","valueInner":"OR:wt.org.WTGroup:25032275469","valueLink":"http://pdmlink.sany.com.cn/Windchill/app/#ptc1/tcomp/infoPage?oid\u003dOR%3Awt.org.WTGroup%3A25032275469\u0026u8\u003d1","required":true,"formType":null,"singleLine":null,"row":2,"col":1,"selects":null},{"label":"项目预算（万元）","id":"ProjectBudget","valueType":"FloatingPoint","value":null,"valueInner":null,"valueLink":null,"required":false,"formType":null,"singleLine":null,"row":2,"col":2,"selects":null},{"label":"编辑者","id":"modifier","valueType":"TypeInstanceIdentifier","value":"王志伟","valueInner":"wangzw14","valueLink":"http://pdmlink.sany.com.cn/Windchill/app/#ptc1/tcomp/infoPage?oid\u003dOR%3Awt.org.WTUser%3A18411389593\u0026u8\u003d1","required":false,"formType":null,"singleLine":null,"row":2,"col":3,"selects":null}]},{"sort":"3","items":[{"label":"项目经理","id":"ProjectMananger","valueType":"String","value":"王志伟","valueInner":"王志伟","valueLink":null,"required":false,"formType":null,"singleLine":null,"row":3,"col":0,"selects":null},{"label":"组织结构","id":"obsReference","valueType":"TypeInstanceIdentifier","value":"重机事业部","valueInner":"OR:com.pisx.pmgt.resource.PIObs:24964298064","valueLink":"http://pdmlink.sany.com.cn/Windchill/app/#ptc1/tcomp/infoPage?oid\u003dOR%3Acom.pisx.pmgt.resource.PIObs%3A24964298064\u0026u8\u003d1","required":false,"formType":null,"singleLine":null,"row":3,"col":1,"selects":null},{"label":"是否规划内项目","id":"isPlanningProject","valueType":"String","value":"否","valueInner":"否","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":3,"col":2,"selects":null},{"label":"上次修改时间","id":"thePersistInfo.modifyStamp","valueType":"Timestamp","value":"2022/03/14","valueInner":"2022/03/14","valueLink":null,"required":false,"formType":null,"singleLine":null,"row":3,"col":3,"selects":null}]},{"sort":"4","items":[{"label":"说明","id":"description","valueType":"String","value":null,"valueInner":null,"valueLink":null,"required":false,"formType":null,"singleLine":null,"row":4,"col":0,"selects":null},{"label":"计划开始时间","id":"planStartDate","valueType":"Timestamp","value":"2022/03/14","valueInner":"2022/03/14","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":4,"col":1,"selects":null},{"label":"计划完成时间","id":"planEndDate","valueType":"Timestamp","value":"2022/03/30","valueInner":"2022/03/30","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":4,"col":2,"selects":null}]},{"sort":"5","items":[{"label":"状态","id":"state.state","valueType":"String","value":"\u003cstrong\u003e待处理\u003c/strong\u003e-申请中-申请完成-立项准备-立项中-驳回立项-已立项-执行中-已验收-暂停-废弃-已结束","valueInner":"PENDING","valueLink":null,"required":true,"formType":null,"singleLine":null,"row":5,"col":0,"selects":null}]}]}]
      arr[0].rows.forEach(function(item) {
        item.items.map((itm) => {
          if(itm.label == "编码"){
            numbers = itm.value
            return
          }
        })
      })
      this.isMdm = true
      sessionStorage.setItem("mdmNumber", numbers)
      this.messList = arr;
      return false;
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getDetailMessage(params).then(res => {
        if (res && res.status === 200) {
           if(res.data && res.data.data !== "" && res.data.success){
             var numbers = null;
             res.data.data[0].rows.forEach(function(item) {
               item.items.map((itm) => {
                 if(itm.label == "编码"){
                   numbers = itm.value
                   return
                 }
               })
             })
             this.isMdm = true
             sessionStorage.setItem("mdmNumber", numbers)
             this.messList = res.data.data;
           }else{
              this.messList = []
              // Message.error("查询失败");
           } 
        } else {
          this.messList = []
          Message.error("查询失败");
        }
      });
    },
    handleOKEditApply() {
      this.visibleModalEditApply = false;
      let params = {
        userId: userinfo.loginName,
        myAppList: this.draggedList
      }
      setMyApply(params).then(res=>{
        if(res.data.result){
          this.getMyApply()
        }
      })
    },
    // 关闭应用编辑页面
    handleCancelEditApply() {
      this.visibleModalEditApply = false
      this.state += 1
    },
    // 获取编辑后的值
    dragged(item){
      let arr = []
      item.forEach(items=>{
        arr.push(items.id)
      })
      this.draggedList = arr.join()
    },
    // 保存设置的状态
    handleOKStatus() {
      this.visibleModalStatus = false;
      let params = {
        oid: this.commonParams.oid,
        userId: userinfo.loginName,
        state: this.statusNow
      }
      setTemplateStatus(params).then(res=>{
        if(res && res.status === 200){
          if(res.data && res.data.success) {
            Message.success("设置成功")
            this.init();
          }else{
          //  Message.error("设置失败")
        }
          
        }else{
           Message.error("设置失败")
        }
      })
    },
    // 我的应用点击跳转
    showModal(item) {
      switch (item.name) {
        case "项目关闭":
          this.$router.push({
            path: "projectMain/closeProject",
            query: {
              oid: this.$route.query.oid,
              flowId: item.url
            }
          });
          break;
        case "设置状态":
          this.visibleModalStatus = true;
          this.getTemplateStatus()
          break;
        case "结项检查":
          this.conclusion();
          break;
        case "编辑项目":
          this.$router.push({
            path: "projectMain/editProject",
            query: {
              oid: this.$route.query.oid
            }
          });
          break;
        case "汇总项目数据":
          this.successData();
          break;
        case "推送项目到RDP":
          this.successTWX();
          break;
        case "上传文档":
          this.openUploadModal()
          break;
        case "更新项目进展":
          this.updateProgress()
          break;
        case "创建结项验收表":
          //  window.open(item.url,"_blank")
          /*获取列表*/
          // getListData() {
            // this.loadVisible = true
            let datas = {
              oid: 'OR:com.pisx.pmgt.project.PIProject:' + this.projectOid
            }
            getCheckList(datas).then(res => {
              if (res && res.status === 200) {
                if (res.data && res.data.data && res.data.data.length > 0) {
                  this.acceptList = res.data.data
                } else {
                  this.acceptList = []
                }
              } else {
                this.$message.error('获取验收表信息失败')
              }
            })
            let typeObj = {
              type: 'create',
              // acceptId: this.isSelectData[0]
            }
            // sessionStorage.setItem('addAcceptListObj', JSON.stringify(typeObj))
            sessionStorage.setItem('createAcceptInfo', JSON.stringify(typeObj))
            let arr = []
            this.acceptList.forEach(v => {
              arr.push(v.acceptancePhase)
            })
            if (arr.indexOf('整体验收') !== -1) {
              this.$message.error('整体验收已创建，不能再次创建！')
            } else if (arr.indexOf('第一阶段验收') !== -1 && arr.indexOf('第二阶段验收') !== -1) {
              this.$message.error('第一阶段和第二阶段验收已创建，不能再次创建！')
            } else {
              // 判断是否存在任务书
              let data = {
                oid: 'OR:com.pisx.pmgt.project.PIProject:' + this.projectOid
              }
              checkCreateKnotItemBook(data).then(res => {
                if (res && res.data.success === "true") {
                  this.$router.push({
                    path: "projectAcceptList/createAcceptList",
                    query: {
                      create: true
                    }
                  })
                } else {
                  this.$message.error(res.data.message)
                }
              })
            }
          // }
          break;
        case "创建项目任务书":
          this.toCreateTaskBook()
          break;
        case "创建问题":
          // window.open(item.url,"_blank")
          this.$router.push({
            path: "/single/questionSingle/addQuestion",
            query: {
              create: true
            }
          })
          break;
        case "创建风险":
          //  window.open(item.url,"_blank")
          this.$router.push({
            path: "/single/riskSingle/createRisk",
            query: {
              create: true
            }
          })
          break;
        case "创建评审":
          this.$router.push({
            path: "reviewSingle/createReview",
            query: {
              create: true
            }
          })
          //  window.open(item.url,"_blank")
          break;
        case "创建变更":
          this.$router.push({path:'/single/projectAlteration/createAlteration',query: {create: true}})
          break;
      }
    },
    toCreateTaskBook() {
      // 还要加创建权限
      if(!this.canCreate) {
        this.$message.error('暂无权限')
      }else if(this.hasTaskBook) {
        this.$message.error('已有任务书，不能创建')
      } else {
        this.$store.dispatch('clearEditStorage')
        sessionStorage.removeItem('bookOid')
        this.$router.push({
          path: "/single/projectPaper/createTaskBook",
          query: {
            create: true
          }
        })
      }
    },
    // 获取创建权限
    _hasCreatePermission() {
      hasCreatePermission({oid: this.commonParams.oid, userId: userinfo.loginName}).then(({data}) => {
        // console.log(data)
        this.canCreate = data.hasAccess
        // 没有创建任务书的权限
        if(!data.hasAccess) {
          this.iconTextList = this.iconTextList.filter(item => item.id !== 'createTaskbook')
        }
      })
    },
    // 获取设置状态
    getTemplateStatus() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getTemplateStatus(params).then(res=>{
       if(res && res.status === 200){
         if(res.data && res.data.data.length > 0 && res.data.success){
          this.statusNow = res.data.data[0].state
          if (res.data.data[0].selects.length > 0) {
            this.targetStatusList = res.data.data[0].selects.filter(v => v.value === 'ProjectStartPrepare')
          } else {
            this.targetStatusList = []
          }
          // this.targetStatusList = res.data.data[0].selects
         }else{
          //  Message.error(res.data.detailMessage);
         }  
       }else{
         Message.error("请求失败");
       }
      })
    },
    // 编辑我的应用
    editApply() {
      this.visibleModalEditApply = true;
      if(this.noDragList !=="" && this.noDragList.length !== 0){
        let newMixData = []
        // let noMixData = []
        this.noDragList.forEach(item=>{
          this.iconTextList.forEach(i=>{
            if(i.id === item){
              newMixData.push({
                name: i.name,
                id: i.id,
                show: true,
                icon: i.icon,
                number: i.number,
                url: i.url,
              })
            }
          })
        })
        this.moreList = this.iconTextList.filter(item=>{
          return this.noDragList.every(v=> v != item.id)
        })
        this.moreList.forEach(item=>{
          item.show = false
        })
        this.applyList = newMixData
      }else{
        this.applyList = this.iconTextList
      }
      
    },
    // 汇总数据
    successData() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getSummaryData(params).then(res => {
        if(res.status == 200 && res) {
          if(res.data && res.data.data.length > 0 && res.data.success){
            if (JSON.parse(res.data.data[0].operateResult)) {
              this.$success({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
            });
            } else {
              this.$error({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            }
          }else{
            // Message.error("获取失败")
          }
        }else{
          Message.error("获取失败")
        }
      });
    },
    //结项检查
    conclusion() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getConclusion(params).then(res => {
        if(res.status == 200 && res) {
          if(res.data && res.data.data && res.data.success){
            if (JSON.parse(res.data.data[0].operateResult)) {
              this.$success({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            } else {
              this.$error({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            }
          }else{
            // Message.error("获取失败")
          }
        }else{
         Message.error("获取失败")
        }
      });
    },
    // 更新项目进展
    updateProgress() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      updateProgress(params).then(res => {
        if(res.status == 200 && res) {
          if(res.data && res.data.data && res.data.success){
            if (JSON.parse(res.data.data[0].operateResult)) {
              this.$success({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            } else {
              this.$error({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            }
          }else{
            // Message.error("获取失败")
          }
        }else{
          Message.error("获取失败")
        }
      });
    },
    // 获取关联产品
    getRelationProduct() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getRelationProduct(params).then(res => {
        if (res && res.status === 200) {
          if (res.data && res.data.data !== "" && res.data.success) {
              const data = res.data.data.map(item => {
              item.partMsg = item.partMsg.replace(/,/g, " -");
              return item;
            });
            this.productList = data;
          }
          this.productList = res.data.data;
        } else {
          Message.error("查询失败");
        }
      });
    },
    // 获取项目看板
    projectBoard() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      getProjectAchieve(params).then(res => {
        if (res && res.status === 200) {
          if(res.data && res.data.data !== "" && res.data.success){
            this.projectAchieve = Number(res.data.data[0].completePercent)
            // this.projectAchieve.explain = "项目进度完成率";
          }
        } else {
          Message.error("查询失败");
        }
      })
      getQuestion(params).then(res => {
        if (res.status === 200 && res) {
          if(res.data && res.data.data !== "" && res.data.success ){
            this.solutionQuestion = res.data.data[0];
            this.solutionQuestion.explain = "已解决/总问题数";
          }
        } else {
          Message.error("查询失败");
        }
      })
      getRisk(params).then(res => {
        if (res && res.status === 200) {
          if(res.data && res.data.data !== "" && res.data.success){
            this.solutionRisk = res.data.data[0];
            this.solutionRisk.explain = "已解决/总风险数";
          }
        } else {
          Message.error("查询失败");
        }
      });
    },
    // 添加产品
    findProduct(value) {
      this.selectedItems = value;
    },
    // 搜索产品
    fetchProduct(value) {
      this.fetch(value, data => (this.filteredOptions = data));
    },
    fetch(value, callback) {
      let _ = this;
      _.fetching = true;
      if (timeout) {
        clearTimeout(timeout);
        timeout = null;
      }
      currentValue = value;
      function fake() {
        let params = {
          key: value,
          userId: userinfo.loginName
        };
        findRelationProject(params).then(res => {
          if (res.status === 200) {
            _.fetching = false;
            const data = res.data.data;
            callback(data);
          } else {
            Message.error("查询失败");
          }
        });
      }
      timeout = setTimeout(fake, 1000);
    },
    // 推至twx
    successTWX() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
      }
      sendThingworxData(params).then(res => {
        if(res.status == 200 && res) {
          if(res.data && res.data.data && res.data.success){
            if (JSON.parse(res.data.data[0].operateResult)) {
              this.$success({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            } else {
              this.$error({
                title: res.data.data[0].msg,
                okText: "确认",
                centered: true
              });
            }
          }else{
            Message.error(res.data.message);
          }
        }else{
            Message.error("查询失败");
        } 
      });
    },
    // 添加产品
    addProduct() {
      let params = {
        userId: userinfo.loginName,
        oid: this.commonParams.oid,
        partOid: this.selectedItems
      };
      addRelationProject(params).then(res => {
        if (res.status === 200 && res) {
          if(res.data.success){
            this.getRelationProduct();
          this.selectedItems = "";
          }else {
          Message.error("添加失败");
          }
          
        } else {
          Message.error("添加失败");
        }
      });
    },
    // 删除产品
    deleteProduct(item) {
      let params = {
        oid: item.oid,
        userId: userinfo.loginName
      };
      removeRelationProject(params).then(res => {
        if (res.status === 200 && res) {
          if(res.data.success){
            Message.success("删除成功");
            this.getRelationProduct();
          }else{
            Message.error("删除失败");
          }
        } else {
          Message.error("删除失败");
        }
      });
    },
    //打开上传交付物弹窗
    openUploadModal() {
      this.visibleDeliver = true
    },
    //关闭上传交付物弹窗
    closeUploadModal() {
      this.visibleDeliver = false
      this.$refs.deliver.clearModal()
    },
  }
};
</script>
<style lang="less" scoped>
@import "./index.less";
</style>
<style lang="less">
.modalStatus {
  .selectStatus {
    display: flex;
    justify-content: flex-start;
    .targetStatus {
      width: 100px;
    }
  }
}
.default a {
  cursor: default;
}
// .ant-carousel .slick-slide{
//   text-align: center;
//   height: 160px;
//   line-height: 160px;
//   background: #fff;
//   overflow: hidden;
// }
// .ant-carousel .slick-dots li.slick-active button{
//   background: #386bd7!important;
//   width: 5px;
//   height: 5px;
//   border-radius: 50%;
// }
// .ant-carousel .slick-list .slick-slide.slick-active{
//   height: 280px;
// }
// .ant-carousel .slick-dots li button{
//   background: #ccc!important;
//   width: 5px;
//   height: 5px;
//   border-radius: 50%;
// }
// .ant-anchor-link{
//   text-align: left;
// }
// .ant-anchor-ink::before{
//   background: transparent!important;
//   border-left: 1px dashed #ccc!important;
// }
// .ant-anchor.fixed .ant-anchor-ink .ant-anchor-ink-ball{
//   display: block;
// }
</style>